package de.tum.in.far.threedui.general;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.LineArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;


public class Line extends Shape3D{
//	public CoordinatesMarker() {
//		Geometry g = new LineArray(0, 0);
//	}
	
	LineArray axes ;
	public Line(Point3f p1, Point3f p2)
	{
		axes = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);

		axes.setCoordinate(0, p1);
		axes.setCoordinate(1, p2);
		axes.setColor(0, new Color3f( getInRange(Math.random()),getInRange(Math.random()),getInRange(Math.random())));
		axes.setColor(1, new Color3f(getInRange(Math.random()),getInRange(Math.random()),getInRange(Math.random())));
		
		axes.setCapability(LineArray.ALLOW_COLOR_WRITE);
		axes.setCapability(LineArray.ALLOW_COLOR_READ);
		
//		axes.set
		setGeometry(axes);
	}
	
	public Line(float px, float py, float pz, float qx, float qy, float qz)
	{
		this(new Point3f(px, py, pz), new Point3f(qx, qy, qz));
	}
	
	float getInRange(double n)
	{
		return (float) Math.min(1, n + 0.3);
	}
	
	

	public static BranchGroup asBranchGroup(Line cm)
	{
		BranchGroup gp = new BranchGroup();
		gp.addChild(cm);
		return gp;
	}
	
	public BranchGroup asBranchGroup()
	{
		BranchGroup gp = new BranchGroup();
		gp.addChild(this);
		return gp;
	}
	
}
